# -*-  conding: utf-8 -*-
# Author: czh
# Datetime : 2022年5月15日11:15:07
import time
from pprint import pprint
import pysnowball as ball
import csv
import pandas as pd

import akshare as ak


def get_circ():
    """
    获取实时
    0代码,1名称,2最新价,3涨跌额,4涨跌幅,5买入,6卖出,7昨收,8今开,9最高,10最低,11成交量,12成交额
    """
    print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()))
    f_csv = pd.read_csv("shishi.csv")
    for idx, data in f_csv.iterrows():
        #  获取股票代码，名称
        symbol_name = data[1].upper()
        sysmbol = symbol_name[:8]
        name = data[2]
        try:
            #  调用接口读取去除流通值低于150的股票 symbol=SZ000998
            res = ball.quotec(sysmbol)
            float_market_capital = float(res["data"][0]["float_market_capital"])
            # 流通值在 150亿以上
            if float_market_capital < 15000000000:
                print(idx)
                # 删除df中数据，并保存
                f_csv.drop([idx], inplace=True)
                f_csv.to_csv('./shishi.csv', index=False)
                # new_name_list.append(name)
        except TypeError:
            print("出现异常：", name)
    # print(len(new_name_list))
    # pprint(new_name_list)

    print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()))


if __name__ == '__main__':
    get_circ()

